;Import notes (a text file with or without numbered notes).  It uses the current text style and layer settings except the user can specify any height desired
;	regardless of the style settings.  The current text size is
;	the default.  In order to indent notes that are numbered
;       the numbers must be alone on the line before the note they
;	refer to AND they must be no longer than three characters
;	INCLUDING a required period.  Any line of three characters or
;	less that ends in a period Will be treated as a note number!
;
;	AUTHOR: HENRY C. FRANCIS
;		425 N. ASHE ST.
;		SOUTHERN PINES, NC 28387
;              
;		All rights reserved without prejudice.
;
;	Copyright:	5-28-96
;	Edited:		5-28-96
;
(defun newerr ( msg / )
  (close filid)
  (setq *error* olderr)
  (princ msg)
)
(defun c:txtin ( / aso10 noipt strtp tstyl texth txfil filid txlin txlst)
  (setq txfil (getfiled "Import Text File" (getvar"dwgprefix") "txt" 4))
  (setq olderr *error*)
  (setq *error* newerr)
  (if (= 1 txfil)
    (princ "\nNo file selected"))

  (IF (AND ureal uint ustr ukword uangle udist) NIL (LOAD "uutils"))
  (IF getstyle NIL (LOAD "getstyle"))
  (getstyle "A")
  (if dimscl nil (load "dimscl"))
  (dimscl)
  (if gvpno nil (load "gvpno"))
  (gvpno)
  (setq thts (ustr 1 "\n\"Leroy Template Size\" or Standard(=110) " (if thts thts "Standard")nil))
  (cond
    ((or(eq (substr thts 1 1)"S")(eq (substr thts 1 1)"s"))
      (setq colr "6"))
    ((<=(atoi thts)80)
      (setq colr "1"))
    ((<=(atoi thts)125)
      (setq colr "6"))
    ((<(atoi thts)200)
      (setq colr "4"))
    ((>=(atoi thts)200)
      (setq colr "2"))
    (thts
      (setq colr "6"))
  );cond
  (IF (OR (EQ (SUBSTR thts 1 1) "S") (EQ (SUBSTR thts 1 1) "s"))
    (SETQ texth (* 0.110 dimsc))
    (SETQ texth (* (* (ATOI thts) 0.001) dimsc))
  ) ;_ end of IF
  (SETVAR "TEXTSIZE" texth)

;  (setq texth (getvar"textsize"))
  (setq tstyl (tblsearch "STYLE" (getvar"textstyle")))
;  (setq newth (ureal 1 "Current" "New text height or Current " (if newth newth texth)))
;  (if (= newth "Current")
    (setq newth texth)
;  )
  (setq colsp (ureal 1 "D" "Indentation"(if colsp colsp (* 3 newth))))
  (setq linsp (ureal 1 "D" "Line spacing"(if linsp linsp (* 1.5 newth))))
  (if (eq colsp "D")(setq colsp (* 3 newth)))
  (if (eq linsp "D")(setq linsp (* 1.5 newth)))
  (setq strtp (upoint 1 "" "Start point, upper left corner" nil nil))
  (setq filid (open txfil "r"))
  (setq txlst
    (list
      (cons 0 "TEXT")
      (cons 40 newth)
      (cons 7 (cdr(assoc 2 tstyl)))
    )
  );setq
  (if (assoc 50 tstyl)
    (setq txlst (append txlst (list(cons 51(cdr(assoc 50 tstyl)))))))
  (if(eq(setq cecolr (getvar"cecolor"))"BYLAYER")nil
    (setq txlst (append txlst (list(cons 62 (atoi cecolr))))))
  (if(eq(setq celtyp (getvar"celtype"))"BYLAYER")nil
    (setq txlst (append txlst (list(cons 6 celtyp)))))
  (while
    (or(setq txlin (read-line filid))(eq txlin ""))
    (setq noipt strtp)
    (setq strtp (polar noipt (* 1.5 pi)linsp))
    (if (/= txlin "")
      (progn
        (if (and(<=(strlen txlin)3)(=(substr txlin(strlen txlin))"."))	;the 3 is max string length and
          (setq aso10 noipt)						;the "." must be the last char.
          (setq aso10 (polar(polar noipt 0 colsp)(* 0.5 pi)linsp))
        )
        (setq ntxlst
          (append txlst
            (list
              (cons 10 aso10)
              (cons 1 txlin)
            ))
        )
        (entmake ntxlst)
      )
    )
  );while
  (close filid)
  (c:rslayr)
  (getstyle "")
  (PRINC)
);defun
